package Socket.TCP;

import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author chetaifu
 */
public class SocketServer {
    public static void main(String[] args) {
        try {
            // 流式socket基于TCP协议
            ServerSocket serverSocket = new ServerSocket(8088);

            // 创建客户端socket
            Socket socket = new Socket();
            while (true) {
                socket = serverSocket.accept();
                ServerThread thread = new ServerThread(socket);
                thread.start();

                InetAddress address = socket.getInetAddress();
                System.out.println("当前客户端的IP：" + address.getHostAddress());
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

}
